package com.mao.wx.demo.model.event;

import java.util.Date;
import java.util.Map;

/**
 * 微信推送的按钮事件通用字段
 * <xml><ToUserName><![CDATA[gh_e136c6e50636]]></ToUserName>
 * <FromUserName><![CDATA[oMgHVjngRipVsoxg6TuX3vz6glDg]]></FromUserName>
 * <CreateTime>1408090502</CreateTime> <MsgType><![CDATA[event]]></MsgType>
 * <Event><![CDATA[type]]></Event> <EventKey><![CDATA[6]]></EventKey>
 * 
 * @author 54353
 *
 */
public class WxBasicEvent {
	
	String ToUserName;
	String FromUserName;
	Long CreateTime;
	String Event;
	String EventKey;
	String MsgType;
	
	public String getMsgType() {
		return MsgType;
	}

	public void setMsgType(String msgType) {
		MsgType = msgType;
	}

	public WxBasicEvent(){
		
	}
	
	public WxBasicEvent(Map<String,String> map)throws Exception{
		this(map,false);
	}
	
	public WxBasicEvent(Map<String,String> map,boolean isResponse)throws Exception{
		if(isResponse){
			this.ToUserName=map.get("FromUserName");
			this.FromUserName=map.get("ToUserName");
			this.CreateTime=new Date().getTime();
			this.Event=map.get("Event");
			this.EventKey=map.get("EventKey");
			this.MsgType=map.get("MsgType");
		}else{
			this.ToUserName=map.get("ToUserName");
			this.FromUserName=map.get("FromUserName");
			this.CreateTime=Long.parseLong(map.get("CreateTime"));
			this.Event=map.get("Event");
			this.EventKey=map.get("EventKey");
			this.MsgType=map.get("MsgType");
		}
	}

	public String getToUserName() {
		return ToUserName;
	}

	public void setToUserName(String toUsername) {
		ToUserName = toUsername;
	}

	public String getFromUserName() {
		return FromUserName;
	}

	public void setFromUserName(String fromUserName) {
		FromUserName = fromUserName;
	}

	public Long getCreateTime() {
		return CreateTime;
	}

	public void setCreateTime(Long createTime) {
		CreateTime = createTime;
	}

	public String getEvent() {
		return Event;
	}

	public void setEvent(String event) {
		Event = event;
	}

	public String getEventKey() {
		return EventKey;
	}

	public void setEventKey(String eventKey) {
		EventKey = eventKey;
	}
	
	
}
